//
//  ViewController.m
//  LuckyTurntable
//
//  Created by 周英培 on 16/7/24.
//  Copyright © 2016年 周英培. All rights reserved.
//

#import "ViewController.h"
#import "ZZLuckyTurntableView.h"
// 遵守协议
@interface ViewController () <ZZLuckyTurntableViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 添加背景图片
    self.view.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"LuckyBackground"].CGImage);
    
    // 加载幸运转盘
    ZZLuckyTurntableView *luckyTurntableView = [ZZLuckyTurntableView luckyTurntableView];
    
    luckyTurntableView.center = CGPointMake(self.view.bounds.size.width *0.5, self.view.bounds.size.height *0.5);
    
    [luckyTurntableView startRotote];
    
    // 设置代理
    luckyTurntableView.delegate = self;
    
    [self.view addSubview:luckyTurntableView];
}

#pragma mark - 实现协议方法
- (void)luckyTurntableView:(ZZLuckyTurntableView *)luckyTurntableView chooseNumber:(NSString *)numStr {

    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:numStr preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *done = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        [luckyTurntableView startRotote];
        
        luckyTurntableView.userInteractionEnabled = YES;
        
    }];
    
    [alertVC addAction:done];
    
    [self presentViewController:alertVC animated:YES completion:nil];
    
}

#pragma mark - 将状态栏改为白色
- (UIStatusBarStyle)preferredStatusBarStyle {

    return UIStatusBarStyleLightContent;
    
}

@end
